/*
 * Copyright (C) 2012, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.utils;

import java.util.Properties;

/**
 *
 * @author Laurent WOUTERS
 */
public class Logger {
    static {
        Properties myProperties = new Properties();
        myProperties.put("log4j.logger.com.hp.hpl.jena", "WARN");
        org.apache.log4j.PatternLayout layout = new org.apache.log4j.PatternLayout("%-5p: %m%n");
        org.apache.log4j.ConsoleAppender appender = new org.apache.log4j.ConsoleAppender(layout);
        org.apache.log4j.BasicConfigurator.configure(appender);
        org.apache.log4j.PropertyConfigurator.configure(myProperties);
    }
    
    private org.apache.log4j.Logger inner;
    
    public Logger(String name, org.apache.log4j.Level level) {
        inner = org.apache.log4j.Logger.getLogger(name);
        inner.setLevel(level);
    }
    
    public void trace(String comp, String msg) { inner.trace("[" + comp + "] " + msg); }
    public void trace(String comp, String msg, Throwable ex) { inner.trace("[" + comp + "] " + msg, ex); }
    public void debug(String comp, String msg) { inner.debug("[" + comp + "] " + msg); }
    public void debug(String comp, String msg, Throwable ex) { inner.debug("[" + comp + "] " + msg, ex); }
    public void info(String comp, String msg) { inner.info("[" + comp + "] " + msg); }
    public void info(String comp, String msg, Throwable ex) { inner.info("[" + comp + "] " + msg, ex); }
    public void warn(String comp, String msg) { inner.warn("[" + comp + "] " + msg); }
    public void warn(String comp, String msg, Throwable ex) { inner.warn("[" + comp + "] " + msg, ex); }
    public void error(String comp, String msg) { inner.error("[" + comp + "] " + msg); }
    public void error(String comp, String msg, Throwable ex) { inner.error("[" + comp + "] " + msg, ex); }
    public void fatal(String comp, String msg) { inner.fatal("[" + comp + "] " + msg); }
    public void fatal(String comp, String msg, Throwable ex) { inner.fatal("[" + comp + "] " + msg, ex); }
}
